<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">回传</a>
            <a><cite>未回传数据</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">链接ID：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="link_id" placeholder="请输入链接ID" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label w-auto">计划ID：</label>
                    <div class="layui-input-inline" style='width:200px'>
                        <input type="text" name="advertiser_id" placeholder="请输入计划ID" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label w-auto">用户ID：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="uid" placeholder="请输入用户ID" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">金额：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="total_fee" placeholder="请输入金额" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">是否首单：</label>
                    <div class="layui-input-inline" >
                        <select name="is_first_recharge" id="is_first_recharge">
                            <option value="">请选择</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="not_return" lay-filter="not_return"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="batchEcho">批量回传</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="back">回传</a>
    </script>

    <script>
        let params = {
            elem: '#not_return'
            , toolbar: '#toolbarDemo'
            , url: '/cps/back/notEchoList' //数据接口
            , id: 'not_return'
            , limit:15
            , page:true
            , cols: [[ //表头
                { type: 'checkbox' },
                { field: 'id', title: '支付ID' ,sort: true, align:'center', width:100}
                , { field: 'link_id', title: '链接ID', align:'center', width:100}
                , { field: 'uid', title: '用户ID', align:'center', width:100}
                , { field: 'activation_time', title: '激活时间', align:'center'}
                // , { field: 'register_time', title: '注册时间', align:'center'}
                , { field: 'order_no', title:'订单号', align:'center'}
                , { field: 'advertiser_id', title:'投放计划ID', align:'center'}
                , { title: '是否首单', width:100, templet: function (d) {
                        return d.is_first_recharge == 1 ? '是' : '否'
                    }, align:'center'
                }
                , { field: 'total_fee', title:'支付金额', align:'center', width:120}
                , { field: 'pay_time', title: '支付时间', templet: function (d) {
                        return dayjsFormat(d.pay_time)
                    }, align:'center'
                }
                , { toolbar: '#tbBar', title: '操作', align: 'center', fixed: 'right', width: 120 }
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(not_return)', function (obj) {
                var event = obj.event;
                if (event === 'batchEcho') {
                    var checkStatus = table.checkStatus('not_return'); 
                    if(checkStatus.data.length === 0){
                        layer.msg('请选择后再操作',{icon:5,time:1000});
                    }else{
                        let id_string = []
                        checkStatus.data.forEach(item=>{
                            id_string.push(item.id)
                        })
                        AnyAjax('确认要回传选中的订单吗？','/cps/back/batchEcho', { id_string:id_string.toString() }, 'not_return')
                    }
                    
                }
            });
            table.on('tool(not_return)', function (obj) {
                var event = obj.event;
                if (event === 'back') {
                    AnyAjax('确认要回传该订单吗？','/cps/back/batchEcho', { id_string: obj.data.id }, 'not_return')
                } 
            });
        });
    </script>
</body>

</html>